package com.yuncheng.spcyApi.lucene;

/*import cn.hutool.core.collection.CollectionUtil;

import com.yuncheng.spcyApi.entity.SpcyFgXcjcwt;
import com.yuncheng.spcyApi.service.ISpcyFgXcjcwtService;
import lucenex.api.FgXcjcwtApi;
import lucenex.po.FgXcjcwtPo;
import org.apache.commons.beanutils.BeanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;*/

/**
 * 现场检查问题-索引
 */
//@Component(value = "fgXcjcwtIndexService")
public class FgXcjcwtIndexService {
    /*private static final Logger log = LoggerFactory.getLogger(FgXcjcwtIndexService.class);

    static final String dataKey = "xcjcwt";

    static final String[] searchKeywords = {"fwtms", "fyzcd"};

    @Resource
    @Lazy
    private ISpcyFgXcjcwtService spcyFgXcjcwtService;

    public void inintXcjcwt(){
        List<SpcyFgXcjcwt> wtList = spcyFgXcjcwtService.list();
        this.initIndexData(wtList);
    }

    public void initIndexData(List<SpcyFgXcjcwt> wtList){
        if (CollectionUtil.isEmpty(wtList)) {
             return;
        }
        addIndexList(wtList);
    }

    public List<FgXcjcwtPo> queryList(String gjz, String fxcjczjid){

        List<FgXcjcwtPo> queryList = FgXcjcwtApi.queryList(gjz, fxcjczjid, dataKey, searchKeywords);

        return queryList;
    }

    public void addIndex(SpcyFgXcjcwt bean){
        FgXcjcwtPo beanPo = new FgXcjcwtPo();

        try {
            BeanUtils.copyProperties(beanPo, bean);
        } catch (IllegalAccessException e) {
            log.error("添加条款索引出错[IllegalAccessException]：{}", e.getMessage());
        } catch (InvocationTargetException e) {
            log.error("添加条款索引出错[InvocationTargetException]：{}", e.getMessage());
        }

        FgXcjcwtApi.AddIndexData(beanPo, dataKey);
    }

    public void addIndexList(List<SpcyFgXcjcwt> beanList){
        List<FgXcjcwtPo> beanPoList = new ArrayList<>();

        beanList.forEach(item -> {
            FgXcjcwtPo beanPo = new FgXcjcwtPo();
            try {
                BeanUtils.copyProperties(beanPo, item);
            } catch (IllegalAccessException e) {
                log.error("添加条款索引出错[IllegalAccessException]：{}", e.getMessage());
            } catch (InvocationTargetException e) {
                log.error("添加条款索引出错[InvocationTargetException]：{}", e.getMessage());
            }
            beanPoList.add(beanPo);
        });

        FgXcjcwtApi.AddIndexData(beanPoList, dataKey);
    }

    public void deleteAllIndex(){

        FgXcjcwtApi.deleteAllIndexData(dataKey);
    }

    public void deleteAllIndexById(String id){

        FgXcjcwtApi.deleteIndexDataById(dataKey, id);
    }*/

}
